programming4us
           
 
 
Programming

iOS SDK : Debugging (part 2) - Watchpoints

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
8/17/2011 11:34:21 AM

Watchpoints

Sometimes you might be interested in having the program pause when a value changes. A watchpoint pauses the program when the watched item’s value changes. Setting a watchpoint is tricky the first time, but then it becomes easy. To set a watchpoint, start the application in the debugger, and when the application pauses at a breakpoint, select the variable in the debugger window’s variable list. Right-click it and select “Watch address of” from the shortcut menu (Figure 4). After you click Continue, if the value changes, the debugger notifies you and pauses (Figure 5). It’s worth noting that watchpoints are not persisted across debugging sessions. Every application launch requires that you reestablish your watchpoints.

Figure 4. Setting a watchpoint

Figure 5. The debugger notifies you when a watchpoint’s value changes.


Try This: Debugging an Application

  1. Create a new Utility Application named Debug.

  2. Select FlipsideView.xib to edit it in the Interface Builder. Select View | Utilities | Show Utilities if necessary and then click the Connections button (tiny arrow in a circle). Remove the connection between the view and the File’s Owner by clicking the tiny X next to Files’s Owner (Figure 6).

    Figure 6. Remove the view from the view controller.
  3. Click the Run button to run the application. Click the Info button in the lower right of the simulator screen, and the application crashes.

  4. Quit the iPhone Simulator and return to Xcode.

  5. Open MainViewController.m and add a breakpoint at the second line in showInfo (Figure 7).

    Figure 7. Debugger window stopped at breakpoint in showInfo
  6. Click the Run button again to run the application. If the Debug Area is not visible, select View | Show Debugger Area.

  7. Try stepping over the next few lines and the application crashes. You now know exactly which line in your code causes the application to crash. Something about presenting the FlipsideViewController caused the crash.

    Tip

    Forgetting to set a File’s Owner view outlet is a common mistake.


  8. Stop the iPhone Simulator and return to Xcode. Remove the breakpoint.

  9. From the main menu, select View | Navigators | Breakpoint.

  10. Click the + in the lower-left corner to create a new breakpoint and select Add Symbolic Breakpoint from the pop-up menu. Type objc_exception_throw for the symbol and click Done (Figure 8). You’ve now set a breakpoint in the code that’s called at the moment the error occurs.

    Figure 8. Adding objc_exception_throw as a breakpoint
  11. Click the Run button to launch the application in the debugger.

  12. Click the Info button, and the application halts at the newly set breakpoint. Open the debugger area, if it is not already open (Figure 9). You may want to drag the slider in the lower left of the window to increase the detail in the stack trace.

    Figure 9. Debugger window paused at objc_exception_throw breakpoint
  13. Notice the upper-left window. This contains the stack listing. Follow the stack down several items, and you see the last thing to occur prior to an NSException is loading the view from the nib. Follow the stack to row 12, click it, and you see the line of code in the view controller that was executed in the right pane (Figure 10). So you know trying to load the view from the nib caused the crash.

    Figure 10. Following the stack trace takes you to an error’s source.
Other -----------------
- iOS SDK : Debugging (part1 )
- iOS SDK : Installing Applications on an iPhone
- Software Testing with Visual Studio Team System 2008 : Web Testing - Recording a test
- Software Testing with Visual Studio Team System 2008 : Unit testing web services & Code coverage unit test
- .NET Debugging : Introduction to the Tools - SOS & SOSEX
- .NET Debugging : CLR 4.0 - Synchronization & Interoperability
- iPhone Programming : Connecting to the Network - Getting Data from the Internet
- iPhone Programming : Connecting to the Network - Sending Email
- Programming Excel with VBA and .NET : Tasks in Visual Basic - Check Results
- Programming Excel with VBA and .NET : Tasks in Visual Basic - Read and Write Files
- Programming Excel with VBA and .NET : Tasks in Visual Basic - Get Dates and Times
- Programming Excel with VBA and .NET : Tasks in Visual Basic - Work with Text
- A Technical Overview of the Mobile Web : THE TECHNICAL CHALLENGES OF MOBILE DEVICES (part 2)
- A Technical Overview of the Mobile Web : THE TECHNICAL CHALLENGES OF MOBILE DEVICES (part 1) - Physical Constraints
- Parallel Programming with Microsoft Visual Studio 2010 : Task Parallelism - Unhandled Exceptions in Tasks
- Parallel Programming with Microsoft Visual Studio 2010 : Introduction to Parallel Tasks
- jQuery 1.3 : DOM Manipulation - Moving elements
- .NET Debugging : Introduction to the Tools - .NET 2.0—Redistributable & .NET 2.0—SDK
- .NET Debugging : Managed Heap and Garbage Collection
- Context and Interception : Custom Component Services (part 3) - The Transaction Management Service
 
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
- First look: Apple Watch

- 3 Tips for Maintaining Your Cell Phone Battery (part 1)

- 3 Tips for Maintaining Your Cell Phone Battery (part 2)
programming4us programming4us